#!/bin/sh

Tumor=$1
Normal=$2




zcat ${vcf_path}/${tumor_normal}.filterStep1.vcf.gz | awk -F'\t' '{if($0~"#" || $7=="PASS")print}' > ${vcf_path}/${tumor_normal}_PASS.vcf


${gatk4} --java-options "-XX:GCTimeLimit=50 -XX:GCHeapFreeLimit=10 -XX:+PrintFlagsFinal \
-XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintGCDetails \
-Xloggc:${log_path}/${Tumor}_${Normal}_gc_log.filterStep1.log \
-Xms5G -Xmx10G -Djava.io.tmpdir=${tmp_path}" \
FilterMutectCalls \
-V ${vcf_path}/${Tumor}_${Normal}.filterStep1.vcf.gz \
-R ${ref_fasta} \
-O ${vcf_qc_path}/${Tumor}_${Normal}.filterStep2.vcf.gz \
--min-median-base-quality 20 \
--min-median-mapping-quality 40 \
--contamination-table ${vcf_path}/${Tumor}_${Normal}_contamination.table \
--tumor-segmentation ${vcf_path}/${Tumor}_${Normal}_segments.table \
--ob-priors ${Tumor}_${Normal}.artifact-priors.tar.gz \
-stats ${Tumor}_${Normal}.merged_vcf.unfiltered.gz.stats \
--filtering-stats ${vcf_qc_path}/${Tumor}_${Normal}.filterStep2.stats \
--min-median-base-quality ${minbasequality} \
--min-median-mapping-quality ${minmapquality} \
--min-median-read-position ${enddistance} \
2> ${log_path}/${Tumor}_${Normal}_filterStep1.log



